package cn.tedu.ivos.dict.service.impl;

import cn.tedu.ivos.dict.mapper.DictMapper;
import cn.tedu.ivos.dict.pojo.dto.DictQuery;
import cn.tedu.ivos.dict.pojo.dto.DictSaveParam;
import cn.tedu.ivos.dict.pojo.entity.Dict;
import cn.tedu.ivos.dict.pojo.vo.DictVO;
import cn.tedu.ivos.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@Slf4j
public class DictServiceImpl implements DictService {
    @Autowired
    private DictMapper dictMapper;
    @Override
    public List<DictVO> selectDict(DictQuery dictQuery) {
       log.debug("查询字典:DictQuery={}", dictQuery);
        List<DictVO> listDictVO = dictMapper.selectDict(dictQuery);
        return listDictVO;
    }

    @Override
    public void insertDict(DictSaveParam dictSaveParam) {
        log.debug("添加字典:DictSaveParam={}", dictSaveParam);
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictSaveParam,dict);
        dict.setStatue("1");
        dict.setCreateTime(new Date());
        dictMapper.insertDict(dict);
    }
}
